/**
 * 
 */
package com.ms.game.itembox.container;

import com.ms.game.itembox.Item;
import com.ms.game.itembox.message.SUseAnimationCardNotify;
import com.ms.player.Player;
import com.ms.player.PlayerNickNameParser;
import com.ms.service.error.ErrorCode;
import com.ms.service.module.zone.module.BasicZoneModule;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.message.MessageAction;
import com.xpec.c4.service.module.common.PlayerCommonInfoManager;

/**
 * 螢幕動畫卡
 * 
 * @author TW15010
 */
public class ItemAnimationCard extends ItemBasic {
	/** 動畫id */
	private String animationId;

	public String getAnimationId() {
		return animationId;
	}

	public void setAnimationId(String animationId) {
		this.animationId = animationId;
	}

	// ServerCore only ================================================

	@Override
	public int use(Player player, Item useItem, int useCount, GUID targetGuid, Object... object) {
		GUID sessionId = PlayerCommonInfoManager.getInstance().getSessionByPlayerGuid(targetGuid);
		
		String sourcePlayerName = PlayerNickNameParser.mergeNickName(player.getName(), player.getNameNumber());
		// 送動畫 id 給目標 client 演出
		sendUseAnimationCardNotifyToClient(sessionId, sourcePlayerName, getDefaultItemId());

		return ErrorCode.SUCCESS;
	}

	/**
	 * 傳送被使用螢幕動畫卡的通知給目標 client
	 * 
	 * @param sessionId
	 *            session id
	 * @param sourcePlayerName
	 *            來源使用者的名字
	 * @param itemId
	 *            道具id
	 */
	public static void sendUseAnimationCardNotifyToClient(GUID sessionId, String sourcePlayerName,
			String itemId) {
		SUseAnimationCardNotify notify = new SUseAnimationCardNotify();
		notify.setSourcePlayerName(sourcePlayerName);
		notify.setItemId(itemId);

		MessageAction.sendMessage(sessionId, MessageTypes.S_ZONE_USE_ANIMATION_CARD_NOTIFY, notify);
	}

	@Override
	public int applyItemToDc(BasicZoneModule zoneModule, Player player, Item useItem, GUID orderId, Object... object) {
		return 0;
	}

}
